from openai import AzureOpenAI
from settings import AZURE_SETTING

AZURE_CONF = AZURE_SETTING


class AzureClient():
    def __init__(self):
        self.client = AzureOpenAI(
            api_key=AZURE_CONF["API_KEY"],
            api_version=AZURE_CONF["API_VERSION"],
            azure_endpoint=AZURE_CONF["API_ENDPOINT"]
        )

    def get_client(self):
        if self.client is None:
            self.recon_client()
        return self.client

    def recon_client(self):
        self.client = AzureOpenAI(
            api_key=AZURE_CONF["API_KEY"],
            api_version=AZURE_CONF["API_VERSION"],
            azure_endpoint=AZURE_CONF["API_ENDPOINT"]
        )


azure_client = AzureClient()
